package com.by.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    /**
     * 获取系统时间 yyyyMM
     *
     * @return
     */
    public static String getSystemYM() {
        LocalDate localDate = LocalDate.now();
        return localDate.format(DateTimeFormatter.ofPattern("yyyyMM"));
    }

    /**
     * 获取系统时间
     *
     * @return
     */
    public static String getSysYm() {
        Calendar calendar = Calendar.getInstance();
        Date now = calendar.getTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
        return format.format(now);
    }

    /**
     * 获取系统时间
     *
     * @return
     */
    public static String getSysTime() {
        Calendar calendar = Calendar.getInstance();
        Date now = calendar.getTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(now);
    }





    public static void main(String[] args) {
        System.out.println(getSystemYM());
        System.out.println(getSysYm());
    }
}
